package com.zhentao;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.zhentao.device.dome.WaterQualityMonitor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.IOException;


@MapperScan({"com.zhentao.login.mapper", "com.zhentao.map.mapper", "com.zhentao.equipment.mapper", "com.zhentao.PollutionPredictio.model.mapper", "com.zhentao.AI.mapper","com.zhentao.device.mapper"})
@SpringBootApplication
@EnableScheduling
public class Application {
    public static void main(String[] args) throws IOException {
        SpringApplication.run(Application.class, args);
        WaterQualityMonitor.initializeConnection();
    }

    @Bean
    MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();

        // 添加分页插件
        PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        // 设置最大单页限制数量，默认 500 条，-1 不受限制
        paginationInterceptor.setMaxLimit(1000L);
        // 设置溢出总页数后是否进行处理
        paginationInterceptor.setOverflow(false);

        mybatisPlusInterceptor.addInnerInterceptor(paginationInterceptor);

        return mybatisPlusInterceptor;
    }
}
